/**
**************************************************************************************
*Founder Effect                                                                      *
*Copyright (C) 2006-2007, 5d Studios (www.5d-Studios.com)                            *
*                                                                                    *
*This library is free software; you can redistribute it and/or                       *
*modify it under the terms of the GNU Lesser General Public                          *
*License as published by the Free Software Foundation; either                        *
*version 2.1 of the License, or (at your option) any later version.                  *
*                                                                                    *
*This library is distributed in the hope that it will be useful,                     *
*but WITHOUT ANY WARRANTY; without even the implied warranty of                      *
*MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU                   *
*Lesser General Public License for more details.                                     *
*                                                                                    *
*You should have received a copy of the GNU Lesser General Public                    *
*License along with this library; if not, write to the Free Software                 *
*Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA      *
**************************************************************************************
*/
#pragma once

#include "../mmanager.h"
#include "Image.h"
#include <vector>
/**
=======================
Represents a series of Images to
be played by a certain amount of time
=======================
*/
class Animation
{
public:
    Animation(void);
    Animation(int fps, int row, int amount );

    /** Set props */
    void Set(int fps, int row, int col, int amount );

    /** Update the animation */
    void Update(long deltaTimeInMSec);

    /** Pause the anim */
    void Pause() { m_pause = true; };
    bool IsPaused() { return m_pause; };
    /** Resume the anim */
    void Resume() { m_pause = false; };

    /** Keep looping the anim */
    bool IsLooping() { return m_looping; };
    void SetLoop(bool b) { m_looping = b; };


    /**
     * Set the current Frame
     */
    void SetFrame(int frame) {
        m_currentFrame = (frame % m_numFrames);
    };
    
    /**
     * Get the current Frame
     */
    int GetFrame() {
        return m_currentFrame + m_col;
    };

    /** Get the row in the image */
    int GetRow() { return m_row; };

    /** Set the frames per sec */
    void SetFPS( int fps ) { if ( fps <= 0 ) fps = 1; m_framesPerMSec =  fps; };
    int GetFPS() { return m_framesPerMSec; } ;

    /** Get the amount of frames */
    int GetNumOfFrames() { return m_numFrames; };
    void SetNumOfFrames( int amount ) { m_numFrames = amount; };

private:
    bool    m_pause;

    /** Looping animation */
    bool    m_looping;
    
    /** Elapsed Time */
    int     m_timeElapsed;
    
    /** Frames / MSec */
    int     m_framesPerMSec;
    
    /** Current Frame */
    int     m_currentFrame;
    
    /** Number of Frames */
    int     m_numFrames;

    /** Row in the image */
    int     m_row;
    /** Col of the image */
    int     m_col;
public:
    virtual ~Animation(void);
};
